<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.apache.commons.lang.StringUtils,java.sql.Connection,java.sql.Statement,java.sql.ResultSet,cn.com.chec.console.dao.DBFactory" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>数据库备份管理</title>
<%@include file="../../common/tagInclude.jsp" %>
<%@include file="../../common/headerInclude.jsp" %>
<script type="text/javascript">
	$(function() {
		$("#jvForm").validate();
	});
	function dbDumpOpr(sqlFile,cate){
		var message = "" ;
		var url = "" ;
		if(cate == 'export'){
			message = "确定导入,将覆盖当前的数据?" ;
			url = "${basePath}admin/dbTable/exportData.do?sqlFile=" + sqlFile ;
		}
		if(cate == 'load'){
			message = "确定下载?" ;
			url = "${basePath}admin/dbTable/dataLoad.do?sqlFile=" + sqlFile ;
		}
		if(cate == 'del'){
			message = "确定删除备份文件?" ;
			url = "${basePath}admin/dbTable/dataDelete.do?sqlFile=" + sqlFile ;
		}
		if(cate == 'delAll'){
			var all_checkbox = document.getElementsByName("sqlFile");
			var len = all_checkbox.length;
			if(isChecked("sqlFile") == false ){
				alert('至少选择一项');
				return ;
			}else{
				var values = "";
				for(var i=0;i<len ;i++){
					if(all_checkbox[i].checked)
						values += "," + all_checkbox[i].value;
				}
				if(values.length > 1)
					values = values.substring(1);
			}
			message = "确定删除所选备份文件?" ;
			sqlFile = values ;
			url = "${basePath}admin/dbTable/dataDeleteAll.do?sqlFile=" + sqlFile ;
		}
		if(!confirm(message))return;
		window.location = url ;
	}
</script>
</head>
<body>
<div class="body-box">
	<div class="rhead">
		<div class="rpos">当前位置: 首页  - 系统 - 数据表 - 数据库备份列表</div>
		<div class="clear"></div>
	</div>
	<form action="${basePath}admin/dbTable/exportList.do" method="post" style="padding-top:5px;">
		<div>
			&nbsp;&nbsp;<a href="javascript:checkAll('sqlFile',true);">全选</a>
			&nbsp;&nbsp;<a href="javascript:checkAll('sqlFile',false);">全不选</a>
			&nbsp;&nbsp;[<a href="javascript:dbDumpOpr('sqlFile','delAll');">删除所选</a>]
		</div>
		<table class="pn-ltable" style="" width="100%" cellspacing="1" cellpadding="0" border="0">
			<thead class="pn-lthead">
			<tr>
				<th>标识</th>
				<th>文件名称</th>
				<th>备份时间</th>
				<th>文件大小</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody class="pn-ltbody">
			<c:forEach items="${sqlFileInfoList}" var="fileInfo" varStatus="status">
			<tr align="center">
				<td><input type="checkbox" name="sqlFile" id="sqlFile" value="${fileInfo.fileName}"/></td>
				<td>${fileInfo.fileName}</td>
				<td>${fileInfo.lastModified}</td>
				<td>${fileInfo.fileSize}B</td>
				<td>
					<a href="javascript:dbDumpOpr('${fileInfo.fileName}','export');">导入</a>&nbsp;&nbsp;
					<a href="javascript:dbDumpOpr('${fileInfo.fileName}','load');">下载</a>&nbsp;&nbsp;
					<a href="javascript:dbDumpOpr('${fileInfo.fileName}','del');">删除</a>&nbsp;&nbsp;
				</td>
			</tr>
			</c:forEach>
			</tbody>
		</table>
		   	<c:set var="pageURL" value="${basePath}admin/dbTable/exportList.do?"/>
		<%@include file="../../common/pages.jsp"%>
	</form>
</div>
</body>
</html>